package com.zh.view.component

import androidx.compose.foundation.layout.*
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

/**
 *
 * @author Zhou
 * @date 9:34 2025/6/4
 */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TopBar(title: String, actions: @Composable RowScope.() -> Unit = {}) {
    Row(
        modifier = Modifier
            .padding(start = 12.dp, end=12.dp, top = 4.dp, bottom = 4.dp)
            .fillMaxWidth() // 确保 Row 占满宽度
            .height(50.dp), // 使用标准高度

        horizontalArrangement = Arrangement.SpaceBetween, // 元素两端对齐
        verticalAlignment = Alignment.CenterVertically // 垂直居中对齐
    ) {
        Text(
            text = title,
            fontSize = 18.sp,
            color = MaterialTheme.colorScheme.onSurfaceVariant
        )
        // 右侧操作区
        Row(
            horizontalArrangement = Arrangement.End, // 操作按钮靠右排列
            verticalAlignment = Alignment.CenterVertically,
            content = actions
        )
    }
}